const UglifyJS = require("uglify-js");
const fs = require("fs");
const path = require("path");
const createDir = require('./createDir');

module.exports = function (input,output) {

    (async () => {
        fs.readFile(input,"utf-8",(err,data)=>{
            createDir(output + path.basename(input))
            fs.writeFile(output + path.basename(input),UglifyJS.minify(data,{toplevel: false}).code,{
                encoding:"utf8"
            },(err)=>{
                if (err) throw err;
                else {
                    console.log('--'+output + path.basename(input)+'--')
                }
            })
        })
    })();


}